<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<script type="text/javascript" src="${staticPath}/static/ckeditor4.10/ckeditor.js"></script>
<style>

</style>
<script type="text/javascript">
    var workCcDataGrid;
    $(function() {
        workCcDataGrid = $('#workCcDataGrid').datagrid({
            url : '${path}/workCc/dataGrid?userId=<shiro:principal property = "id"/>',
            striped : true,
            rownumbers : true,
            pagination : true,
            singleSelect : true,
            idField : 'id',
            sortName : 'id',
            sortOrder : 'asc',
            pageSize : 20,
            pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ],
            columns : [ [
                {
                    width : '300',
                    title : '标题',
                    field : 'title'
                },
                {
                    width : '100',
                    title : '类型',
                    field : 'typeName'
                },

               {
                    width : '100',
                    title : '状态',
                    field : 'status',
                    formatter:function (value,row,index) {
                        if(value==1){
                            return "已读"
                        }
                        return "未读"
                    }
                },
                {
                    width : '100',
                    title : '创建时间',
                    field : 'createTime',
                    formatter:function (value,row,index) {
                        return datetime2Str(value);
                    }
                }
            ]],
            frozenColumns : [ [{
                field : 'action',
                title : '操作',
                width : 100,
                formatter : function(value, row, index) {
                    var str = '';
                    str += $.formatString('<a href="javascript:void(0)" class="workCc-easyui-linkbutton-view" data-options="plain:true,iconCls:\'fi-magnifying-glass\'" onclick="viewworkCcFun(\'{0}\',\'{1}\');" >查看</a>',row.id, row.operatorURL);
                    return str;
                }
            } ] ],
            onLoadSuccess:function(data){
                $('.workCc-easyui-linkbutton-view').linkbutton({text:'查看'});
            },
            toolbar : '#workCcToolbar'
        });
    });

    function viewworkCcFun(id,url) {
        $.ajax({
            url:'${ctxPath}/workCc/read/'+id,
            dataType:'json',
            success:function(result){
                if(result.success){
                    var dialog=parent.$.modalDialog({
                        title : '查看',
                        width : '80%',
                        height : '80%',
                        href : url,
                        buttons : [ {
                            text : '关闭',
                            handler : function() {
                                dialog.dialog('close');
                                workCcDataGrid.datagrid('reload');
                            }
                        } ]
                    });
                }else{
                    parent.$.messager.alert('提示', result.msg, 'error');
                }
            }
        })

    }
    function searchworkCcFun() {
        workCcDataGrid.datagrid('load', $.serializeObject($('#searchworkCcForm')));
    }
    function cleanworkCcFun() {
        document.getElementById('searchworkCcForm').reset();
        workCcDataGrid.datagrid('load', {});
    }
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:false">
        <table id="workCcDataGrid" data-options="fit:true,border:false"></table>
    </div>
</div>
<div id="workCcToolbar" style="display: none;">
    <form id="searchworkCcForm">
        <table>
            <tr>
                <td>标题</td>
                <td>
                    <input name="name"   type="text" placeholder="请输入标题" class="easyui-text  span2" >
                </td>
                <td>日期</td>
                <td>
                <td>
                    <input type="text" name="createTimeStart" class="easyui-text" onclick="WdatePicker()">~
                    <input type="text" name=""createTimeEnd" class="easyui-text" onclick="WdatePicker()">
                </td>
                <td>
                    状态
                </td>
                <td>
                    <select name="status" class="easyui-text">
                        <option value="">--- 请选择 ---</option>
                        <option value="0">未读</option>
                        <option value="1">已读</option>
                    </select>
                </td>
                <td>
                    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fi-magnifying-glass',plain:true" onclick="searchworkCcFun();">查询</a>
                    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fi-x-circle',plain:true" onclick="cleanworkCcFun();">清空</a>
                </td></tr>

        </table>
    </form>
</div>
